#include<stdio.h>
#include<sys/types.h>
#include<pwd.h>
#include<unistd.h>
#include<signal.h>
#include<string.h>
static void my_alarm(int signo)
{
	struct passwd *rootptr;

	printf("in signal handler\n");
/*	if((rootptr = getpwnam("root")) == NULL)
	{
		printf("getpwnam root error\n");
	}*/
    alarm(2); 	
}
int main(int argc,char **argv)
{
	struct passwd *ptr;

	signal(SIGALRM,my_alarm);
	alarm(2);
	for( ; ; )
	{
		if((ptr = getpwnam("yangzhengqing")) == NULL)
		{
			printf("getpwnam yangzhengqing error\n");
		}

		if(strcmp(ptr->pw_name,"yangzhengqing") != 0)
		{
			printf("return value corrupted! pw_name = %s\n",ptr->pw_name);
		}
	}
	return 0;
}
